home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: 500 MB Amiga Software / 500 MB Amiga Software - Euber 130 - Amiga Games Disc & Mag.iso / userbox / publicdomain / tinymeter / source / tinymeter_main / miscfuncs.c < prev    next >
C/C++ Source or Header  |  1995-10-09  |  3KB  |  85 lines

  1. #include <intuition/intuition.h>
  2. #include <devices/timer.h>
  3. #include <clib/macros.h>
  4.  
  5. extern struct Window        *my_window;
  6.  
  7. SaveRectFill(struct RastPort *rp, WORD x, WORD y, WORD x_siz, WORD y_siz)
  8. {
  9.     if((x>=0)&(y>=0)&(x_siz>0)&(y_siz>0)&(x+x_siz<=my_window->Width)&(y+y_siz<=my_window->Height))
  10.     {
  11.         RectFill(rp,x,y,x+x_siz-1,y+y_siz-1);
  12.     }
  13. }
  14.  
  15. UBYTE long_2_string_with_thousand(ULONG num, char output[], char point)
  16. {
  17.     char             output_private[16];
  18.     char             n      = 0;
  19.     char             n_1    = 0;
  20.     sprintf_exec(output_private,"%12ld",num);
  21.     while(output_private[n]==0x20)n++;
  22.     for(;(output_private[n]!=0)&(output_private[n]!=0x20);n++)
  23.     {
  24.         output[n_1++]=output_private[n];
  25.         if((n==2)||(n==5)||(n==8)) output[n_1++]=(char)point;
  26.     }
  27.     output[n_1]=0;
  28.     return(n_1);
  29. }
  30.  
  31. my_strlen(char s[])           /*liefert die Laenge von s */
  32. {
  33.    int i=0;
  34.    while (s[i]!='\0')++i;
  35.    return(i);
  36. }
  37.  
  38. ULONG p2s(ULONG wanted_size, ULONG base, ULONG gauge_x_size)
  39. {
  40.     return((ULONG)((gauge_x_size)-(((wanted_size>>8)*gauge_x_size)/(base>>8))));
  41. }
  42.  
  43. void draw_a_border(ULONG b_x1, ULONG b_y1, ULONG b_x2, ULONG b_y2, int b_col1, int b_col2, struct RastPort *rp)
  44. {
  45.     SetAPen(rp,b_col2);
  46.     RectFill(rp,b_x2,b_y1+1,b_x2,b_y2);
  47.     RectFill(rp,b_x1,b_y2,b_x2,b_y2);
  48.     SetAPen(rp,b_col1);
  49.     RectFill(rp,b_x1,b_y1,b_x1,b_y2-1);
  50.     RectFill(rp,b_x1,b_y1,b_x2-1,b_y1);
  51. }
  52.  
  53. void CopyTiledBitMap(struct BitMap *Src,WORD SrcSizeX,WORD SrcSizeY,struct RastPort *Dst)
  54. {
  55.     WORD PosX,
  56.          PosY;        
  57.     WORD SizeX,
  58.          SizeY;
  59.     for (PosX = 0,SizeX = MIN(SrcSizeX,my_window->Width);PosX<my_window->Width;)
  60.     {
  61.         for (PosY = 0,SizeY = MIN(SrcSizeY,my_window->Height);PosY<my_window->Height;)
  62.         {
  63.                 BltBitMapRastPort(Src,0,0,Dst,PosX,PosY,SizeX,SizeY,0xC0);
  64.                 PosY += MIN(SizeY,my_window->Height-PosY);
  65.                 SizeY = MIN(SizeY,my_window->Height-PosY);
  66.         }
  67.         PosX += MIN(SizeX,my_window->Width-PosX);
  68.         SizeX = MIN(SizeX,my_window->Width-PosX);
  69.     }
  70. }
  71.  
  72. init_time_request(struct timerequest *my_time_request_clock, ULONG my_time_mask_clock)
  73. {
  74.     ULONG interval;
  75.     my_time_request_clock -> tr_node.io_Command     = TR_GETSYSTIME;
  76.     DoIO(my_time_request_clock);
  77.     interval=my_time_request_clock -> tr_time.tv_secs;
  78.     my_time_request_clock -> tr_node.io_Command     = TR_ADDREQUEST;
  79.     my_time_request_clock -> tr_time.tv_secs        = interval+1;
  80.     my_time_request_clock -> tr_time.tv_micro       = 0;
  81.     SetSignal(0,my_time_mask_clock);
  82.     SendIO(my_time_request_clock);
  83. }
  84.  
  85.